//
//  CommonConstant.swift
//  CommonTool
//
//  Created by tenroadshow on 12.1.22.
//

import UIKit

typealias CC = CommonConstant
public struct CommonConstant {

    public static var isX : Bool {
        var isX = false
        if #available(iOS 11.0, *) {
            let bottom : CGFloat = UIApplication.shared.delegate?.window??.safeAreaInsets.bottom ?? 0
            isX = bottom > 0.0
        }
        return isX
    }
    
    public static let screenW = UIScreen.main.bounds.size.width
    public static let screenH = UIScreen.main.bounds.size.height
    
    public static var statusBarHeight : CGFloat { (isX ? 44.0 : 20.0) }
    
    public static var navBarHeight: CGFloat { 44.0 }

    public static var statusWithNavBarHeight: CGFloat { statusBarHeight + navBarHeight }
    
    public static var tabbarHeight: CGFloat { 49.0 }
    
    public static var bottomSafeHeight : CGFloat { (isX ? 34.0 : 0.0) }

    public static var tabbarWithBottomSafe: CGFloat { tabbarHeight + bottomSafeHeight }
    
    public static func scaleW(_ width: CGFloat,fit:CGFloat = 375.0) -> CGFloat { screenW / fit * width }

    public static func scaleH(_ height: CGFloat,fit:CGFloat = 812.0) -> CGFloat { screenH / fit * height }

}



extension CC {
    // MARK: 全局打印
    static func log(_ items: Any...,
                    separator: String = " ",
                    terminator: String = "\n",
                    file: String = #file,
                    line: Int = #line,
                    method: String = #function)
    {
        #if DEBUG
        print("\((file as NSString).lastPathComponent)[\(line)], \(method)", terminator: separator)
        var i = 0
        let j = items.count
        for a in items {
            i += 1
            print(" ",a, terminator:i == j ? terminator: separator)
        }
        #endif
    }
}



